﻿using FairyGUI;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
using WgFrame.Net;

public class ItemTipPanel : BasePopupPanel
{
    private InitItem InitItem;
    /// <summary>
    /// 名称
    /// </summary>
    private GTextField tfName;
    /// <summary>
    /// 描述
    /// </summary>
    private GTextField tfDescribe;
    /// <summary>
    /// 来源
    /// </summary>
    private GTextField tfSource;

    public override void Init()
    {
        base.Init();

        frame = view.GetChild("frame").asCom;
        tfName = frame.GetChild("n3").asTextField;
        tfDescribe = frame.GetChild("n4").asTextField;
        tfSource = frame.GetChild("n5").asTextField;
    }

    public override void Show(params object[] para)
    {
        this.InitItem = para[0] as InitItem;
        this.SetInfo();

        base.Show(para);
    }

    public override void Close()
    {
        InitItem = null;
        base.Close();
    }

    protected override GComponent CreateView()
    {
        return UIPackage.CreateObject("Main", "panel_item_tip1").asCom;
    }

    private void SetInfo()
    {
        tfName.text = InitItem.name;
        tfDescribe.text = InitItem.info;
        if (string.IsNullOrEmpty(InitItem.source))
        {
            tfSource.visible = false;
        }
        else
        {
            tfSource.visible = true;
            tfSource.SetVar("text", InitItem.source).FlushVars();
        }
    }
}
